﻿
<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ page import="cn.ac.cintcm.dataconverge.researcher.domain.Researcher" %>
<%@ page import="cn.ac.cintcm.dataconverge.util.Constants" %>
<%@ include file="/WEB-INF/jsp/taglib.jsp"%>
<%@ include file="/WEB-INF/jsp/include/script.jsp" %>   
<%@ taglib prefix="ec" uri="/WEB-INF/taglib/extremecomponents.tld" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>    
    <title>DataConverge</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <link type="text/css" rel="stylesheet" href="css/xtree.css">
	<script src="js/xtree.js"></script>
    <script type="text/javascript">	
     var id;
     var page;
     function addOrg(){
     	id=document.form0.subjectId.value;
     	page=document.form0.page.value;
	    if(id==""){
	    	return;
	    }	   
	   // alert(id);
	  	document.location.href = "subject.htm?action=gotoAddOrg&subjectId="+id+"&page="+page;
	  }
	  
	  function addResearcher(){
	  	id=document.form0.subjectId.value;
     	page=document.form0.page.value;
	    if(id==""){
	    	return;
	    }	
	    document.location.href ="subject.htm?action=gotoAddResearcher&subjectId="+id+"&page="+page;
	  }
	  
	  function checkManage(){
	    id=document.form0.subjectId.value;
     	page=document.form0.page.value;
	    if(id==""){
	    	return;
	    }	
	  	document.location.href="checkManage.htm?subjectId="+id+"&page="+page;
	  }
	  
	  function uploadStatement(){
	  	id=document.form0.subjectId.value;
     	page=document.form0.page.value;
	    if(id==""){
	    	return;
	    }	
	  	document.location.href="document.htm?subjectId="+id+"&page="+page;
	  }
	  
	  function processManage(){
	  	id=document.form0.subjectId.value;
     	page=document.form0.page.value;
	    if(id==""){
	    	return;
	    }	
	  	document.location.href="fund.htm?subjectId="+id+"&page="+page;
	  }
    		
		function setStatus(value){
			document.getElementById("status").value=value;
			
			var parentNode=document.getElementById("tagIdPlace");
			var docu=document.frames("tagTreeFrame").document;
			var tagId;
			var input;
			for(i=0;i<docu.all.tags.length;i++){
					tagId=docu.all.tags[i].value;
					//alert(tagId);
					input=document.createElement("input");
					input.type="checkbox";
					input.name="tags";
					input.value=tagId;
					parentNode.appendChild(input);
					
					if(docu.all.tags[i].checked==true){
						parentNode.lastChild.checked=true;
					}
					
			}
		}
		function goback(){
			page=document.form0.page.value;
			<%Researcher user=(Researcher) request.getSession().getAttribute(Constants.USER_IN_SESSION); 
     		if(user!=null)  {
      		%>
     		 document.location.href="subject.htm?action=listMySubjects";
    		<%}else{%>    
      		 document.location.href="subjectSearch.htm";
    		<%}%>
			//document.location.href="subject.htm?action=listMySubjects"
			/*if(page!=""){
				document.location.href='subject.htm?ec_p='+page;
			}
			else{
				document.location.href="subject.htm";
			}*/
		}
		function gobacksch(){
      	var page=document.form0.page.value;
      	//alert('${my}');
      	if(page!=""){
      	    if('${my}'=='N')
      		document.location.href='subject.htm?action=listSchSubjects&ec_p='+page;
      		else if('${my}'=='Y')
      		document.location.href='subject.htm?action=listMySubjects&ec_p='+page;
      		else
      		//my==s;
      		document.location.href='subject.htm?action=listMyJoinedSubjects&ec_p='+page;
      	}else{
      		if('${my}'=='N')
      		document.location.href='subject.htm?action=listSchSubjects';
      		else if('${my}'=='Y')
      		document.location.href='subject.htm?action=listMySubjects';
      		else
      		document.location.href='subject.htm?action=listMyJoinedSubjects';
      	}
      }
		function checkForm(){
			var fo=document.form0;
			var exp = new RegExp("^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$");
			if(fo.subjectName.value==""){
				alert("请填写课题名称");
				return false;
			}
			if(fo.applyDate.value!="" && !exp.test(fo.applyDate.value)){
      			alert("请确认申报日期的格式!");
     			fo.applyDate.focus();
	  			return false;
	  		}
			if(fo.permitDate.value!="" && !exp.test(fo.permitDate.value)){
      			alert("请确认中标日期的格式!");
     			fo.permitDate.focus();
	  			return false;
	  		}
			if(fo.startDate.value!="" && !exp.test(fo.startDate.value)){
      			alert("请确认计划起始日期的格式!");
     			fo.startDate.focus();
	  			return false;
	  		}

			if(fo.endDate.value!="" && !exp.test(fo.endDate.value)){
      			alert("请确认计划结束日期的格式!");
     			fo.endDate.focus();
	  			return false;
	  		}   
	  		if(fo.endSubDate.value!="" && !exp.test(fo.endSubDate.value)){
      			alert("请确认结题日期的格式!");
     			fo.endDate.focus();
	  			return false;
	  		}  
			return true;
		}
	</script>
  </head>
  
  <body>
<table width="100%"  border="0" bgcolor="#99CCFF" align="center">
  <tr>
    <td align="center">
  	 	可对此课题进行如下操作:
  	 	<input type="radio" name="oper" onclick="addOrg();">管理单位&nbsp;&nbsp;
  	 	<input type="radio" name="oper" onclick="addResearcher();">安排人员&nbsp;&nbsp;
  	 	<c:if test="${advise=='Y'&&(subject.state=='6'||subject.state=='1')}">
  	 	<input type="radio" name="oper" onclick="checkManage();">确认中标&nbsp;&nbsp;
  	 	</c:if>
  	 	<input type="radio" name="oper" onclick="uploadStatement();">管理文档&nbsp;&nbsp;
  	 	<input type="radio" name="oper" onclick="processManage();">管理经费
    </td>
  </tr>
</table>
<form name="form0"  action="subjectModify.htm" method="post">
<IFRAME id="CalFrame"  
  style="DISPLAY: none; Z-INDEX: 100; WIDTH: 148px; POSITION: absolute;HEIGHT: 194px; left: 42px; top: 50px "
  marginWidth="0" marginHeight="0" 
  src="js/calendar/calendars.html" frameBorder="0"  
  noResize scrolling="no">
</IFRAME>
<input type="hidden" name="subjectId" value="${subject.id}"> 	
<input type="hidden" name="page" value="${page}">
<table width="95%" align="center" height="75%">
<tr>
<td width="30%">
<iframe width="260" height="100%" name="tagTreeFrame" frameborder="0" src="tagTree.htm?oper=add">
</iframe>
</td>
<td width="70%">
<font color="red">${msg}</font>
<table width="100%" border="1"> 
  <tr style="display:none;">
  	<td id="tagIdPlace" colspan="4"></td>
  </tr>
  <tr>
    <td>课题名称</td>
    <td colspan="3"><input name="subjectName" type="text" size="50" value="${subject.subjectName}"/><font color="red">*</font>
    &nbsp;&nbsp;&nbsp;<c:if test="${advise=='N'}">
    <input type="checkbox" name="advise" <c:if test="${subject.state=='6'}">checked</c:if>><font color="red">推荐中标</font>
    </c:if></td>
     
  </tr>
  <tr>
    <td>所属年份</td>
    <td colspan="3"><input name="belongYear" type="text"  value="${subject.belongYear}"/></td>
  </tr>
  <tr>
    <td>课题分类</td>
    <td colspan="3">
    	<c:forEach items="${subject.tags}" var="tag">
    		<c:out value="${tag.name}"/>
    	</c:forEach>&nbsp;		
	</td>
  </tr>
  <tr>
    <td>课题负责人</td>
    <td colspan="3">
    	<c:forEach items="${subject.chargemen}" var="chargeman">
    		<c:out value="${chargeman.name}"/>
    	</c:forEach>&nbsp;
	</td>
  </tr>
  <tr>
    <td>牵头单位</td>
    <td colspan="3">    	
    	<c:out value="${mainOrgNames}"/>&nbsp;
	</td>
  </tr>
  <tr>
    <td>申报日期</td>
    <td><input name="applyDate" type="text" size="10" value="${subject.applyDate}" onClick="ShowCalendar(this,this,null,0);" onkeydown="HideCalendar();" onblur="setFormatDate(this);">
    <font color="red">日期格式：yyyy-mm-dd</font></td>
    <td>中标日期</td>
    <td><input name="permitDate" type="text" size="10" value="${subject.permitDate}" onClick="ShowCalendar(this,this,null,0);" onkeydown="HideCalendar();" onblur="setFormatDate(this);">
    </td>
  </tr>
  <tr>
    <td>计划起始日期</td>
    <td><input name="startDate" type="text" size="10" value="${subject.startDate}" onClick="ShowCalendar(this,this,null,0);" onkeydown="HideCalendar();" onblur="setFormatDate(this);">
    </td>
    <td>计划结束日期</td>
    <td><input name="endDate" type="text" size="10" value="${subject.endDate}" onClick="ShowCalendar(this,this,null,0);" onkeydown="HideCalendar();" onblur="setFormatDate(this);">
    </td>
  </tr>
  <tr>
    <td>结题日期</td>
    <td><input type="text" name="endSubDate" size="10" value="${subject.endSubDate}" onClick="ShowCalendar(this,this,null,0);" onkeydown="HideCalendar();" onblur="setFormatDate(this);">
    </td>
    <td>课题状态</td>
    <td>
    			<c:if test="${subject.state=='0'}">          		
            	 	<c:out value="申报中"/>           	
              	</c:if>
             	<c:if test="${subject.state=='1'}">
            	 	<c:out value="中标"/>     
             	</c:if>
              	<c:if test="${subject.state=='2'}">
            		<c:out value="在研"/>
             	</c:if>                      
 				<c:if test="${subject.state=='3'}">
            		<c:out value="申请结题"/>
            	</c:if>
            	<c:if test="${subject.state=='4'}">          		
            		<c:out value="已结题"/>
            	</c:if>
            	<c:if test="${subject.state=='5'}">
            		<c:out value="未中标"/>
            	</c:if>
    </td>
  </tr>
  <tr>
    <td>申请经费</td>
    <td><input type="text" name="applyFund" size="10" value="${subject.applyFund}">万元</td>
    <td>中标经费</td>
    <td><input type="text" name="permitFund" size="10" value="${subject.permitFund}">万元</td>
  </tr>
  <tr>
    <td>实获经费</td>
    <td colspan="3"><c:out value="${fundDetail}"/></td>
  </tr>
  <tr>
    <td>项目内容概述</td>
    <td colspan="3"><textarea name="content"  rows="7" cols="56"><c:out value="${subject.content}"/></textarea></td>
  </tr>
  <tr style="display:none;">
  	<td><input type="hidden" id="status" name="status" value="modify"></td>
  </tr>
 </table>
 </td>
 </tr>
 </table>
 <br/>
 <div align="center">
 	<c:if test="${subject.state=='5'}">
 		<input type="submit" value="重新申报" onclick="setStatus('reApply');return checkForm();">&nbsp;&nbsp;
 	</c:if>
 	<c:if test="${subject.state!='1'}">
 	<input type="submit" value="提交修改" onclick="setStatus('modify');return checkForm();">&nbsp;&nbsp;
 	</c:if>
 	&nbsp;&nbsp;<input type="button" value="返回" onclick="gobacksch();">
 </div>
 </form>
  </body>
</html>
